//
//  ViewController.m
//  10-掌握-mapkit框架-基本使用
//
//  Created by J on 16/2/28.
//  Copyright © 2016年 J. All rights reserved.
//

#import "ViewController.h"
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>

@interface ViewController ()<MKMapViewDelegate>
@property (weak, nonatomic) IBOutlet MKMapView *mapVIew;
@property (strong, nonatomic)  CLLocationManager *manager;


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.manager = [CLLocationManager new];
    [self.manager requestAlwaysAuthorization];


}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
   
    typedef NS_ENUM(NSUInteger, MKMapType) {
        MKMapTypeStandard = 0,
        MKMapTypeSatellite,
        MKMapTypeHybrid,
        MKMapTypeSatelliteFlyover NS_ENUM_AVAILABLE(10_11, 9_0),//3D卫星
        MKMapTypeHybridFlyover NS_ENUM_AVAILABLE(10_11, 9_0),//3D混合
    } NS_ENUM_AVAILABLE(10_9, 3_0) __WATCHOS_PROHIBITED;

    
    self.mapVIew.mapType =  MKMapTypeSatelliteFlyover;
//    self.mapVIew.zoomEnabled = NO;//缩放
    self.mapVIew.showsCompass = NO;
    self.mapVIew.showsUserLocation = YES;
    self.mapVIew.userTrackingMode = MKUserTrackingModeFollow;//地图会自动放大
}


//更新到位置
//MKUserLocation位置对象
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation{
    
    userLocation.title = @"小码哥";
    userLocation.subtitle = @"大神一期";
    //设置地图显示中心
    [self.mapVIew setCenterCoordinate:userLocation.location.coordinate animated:YES];
    //设置地图显示区域
    MKCoordinateRegion resion = MKCoordinateRegionMake(userLocation.location.coordinate, MKCoordinateSpanMake(0.0001, 0.001000));
    [self.mapVIew setRegion:resion];
    
    
}

//区域已经改变
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated{
    NSLog(@"%f %f",mapView.region.span.latitudeDelta,mapView.region.span.longitudeDelta);
    
    
}

@end
